package com.appbee.core.client.rpcfilter.chain;

import com.appbee.core.client.rpcfilter.RpcFilter;
import com.appbee.core.client.rpcfilter.RpcFilterChain;
import com.appbee.core.client.rpcfilter.callback.FilterCallback;

public class RpcFilterChainImpl<I, R> implements RpcFilterChain<I, R>
{
	private RpcFilter<I, R> layer;

	private RpcFilterChain<I, R> chain;

	public RpcFilterChainImpl(RpcFilter<I, R> layer)
	{
		this.layer = layer;
	}

	@Override
	public void doFilter(I input, FilterCallback<R> callback)
	{
		layer.doFilter(input, callback, chain);
	}

	public RpcFilterChainImpl<I, R> chain(RpcFilter<I, R> layer)
	{
		RpcFilterChainImpl<I, R> chainImpl = new RpcFilterChainImpl<I, R>(layer);
		this.chain = chainImpl;
		return chainImpl;
	}

	public RpcFilterChain<I, R> getChain()
	{
		return chain;
	}

	public void setChain(RpcFilterChain<I, R> chain)
	{
		this.chain = chain;
	}

}
